home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / OUI / gadget.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  1.3 KB  |  57 lines

  1. // $Id: gadget.cc 1.3 1997/09/17 08:15:46 dlorre Exp dlorre $
  2. #include <libraries/gadtools.h>
  3.  
  4. #include "gadgets/gadget.h"
  5. #include "gadgetlist.h"
  6. #include <ctype.h>
  7. #include <mydebug.h>
  8.  
  9. // ========================================================================
  10. // ==========================  GADGET CLASS ===============================
  11. // ========================================================================
  12.  
  13.  
  14. gadget::gadget(gadgetlist *gl,
  15.                void (window::*func)(gadget *, unsigned long, unsigned short)
  16.                ) : glist(gl), gfunc(func), gad(NULL)
  17. {
  18.     gl->ng->ng_LeftEdge = gl->left ;
  19.     gl->ng->ng_TopEdge = gl->top ;
  20.     gl->ng->ng_Width = gl->width ;
  21.     gl->ng->ng_Height = gl->height ;
  22.     id = gl->ng->ng_GadgetID = gl->count ;
  23.     gl->gtab[gl->count] = this ;
  24.     gl->count++ ;
  25.     w = gl->wp ;
  26.     key = '\0' ;
  27. }
  28.  
  29. void gadget::action(unsigned long classe, unsigned short code)
  30. {
  31.     if (gfunc) (glist->win->*gfunc)(this, classe, code) ;
  32. }
  33.  
  34. void gadget::select(BOOL sel)
  35. {
  36. }
  37.  
  38. void gadget::keystroke(BOOL shifted)
  39. {
  40. }
  41.  
  42. void gadget::underkey(const char *s)
  43. {
  44. int i ;
  45.  
  46.     key = '\0' ;
  47.     if (s && *s) {
  48.         for (i=1 ; s[i] ; i++) {
  49.             if (s[i-1] == '_' ) {
  50.                 key = tolower(s[i]) ;
  51.                 break ;
  52.             }
  53.         }
  54.     }
  55. }
  56.  
  57.